import { adminImg } from "@/api/content.js";

export let adImg = {
    namespaced: true,
    state: () => ({ 
        banners: [],
        adv: [],
        actives: [],
     }),
    mutations: { 
        async getBanners(state){
            let data = await adminImg.banner.getAll();
            data.forEach(item => {
                item.showEditDialog = false
            });
            state.banners = data;
        },
        pushBanner(state, banner){
            state.banners.push(banner)
        },
        spliceBanner(state, index){
            state.banners.splice(index)
        },

        async getAdv(state){
            let data = await adminImg.adv.getAll();
            data.forEach(item => {
                item.showEditDialog = false
            });
            state.adv = data;
        },
        pushAdv(state, adv){
            state.adv.push(adv)
        },
        spliceAdv(state, index){
            state.adv.splice(index)
        },
        

        async getActives(state){
            let data = await adminImg.active.getAll();
            data.forEach(item => {
                item.showEditDialog = false
            });
            state.actives = data;
        },
        pushActive(state, active){
            state.actives.push(active)
        },
        spliceActive(state, index){
            state.actives.splice(index)
        },
    },
}